local lincai = fk.CreateSkill{
  name = "xiaobai__lincai"
}

Fk:loadTranslationTable{
  ["xiaobai__lincai"] = "遴才",
  [":xiaobai__lincai"] = "当你受到伤害后，你可以令一名装备区牌数不大于X的角色摸两张牌（X为“进替”中“摸至四张”之前的项数）。",
  ["#lincai-choose"] = "遴才：你可以选择一名装备数不大于%arg的角色令其摸两张牌"
}

lincai:addEffect(fk.Damaged, {
  anim_type = "masochism",
  on_cost = function(self, event, target, player, data)
    local room = player.room
    local targets = room.alive_players
    targets = table.filter(targets,function (element, index, array)
      return #element:getCardIds("e") <= player:getMark("xiaobai__jinti")-1
    end)
    local to = room:askToChoosePlayers(player, {
      targets = targets, 
      min_num = 1,
      max_num = 1,
      prompt = "#lincai-choose:::"..(player:getMark("xiaobai__jinti")-1), 
      skill_name = self.name,
      cancelable = true})
    if #to > 0 then
      event:setCostData(self, {tos = to})
      return true
    end
    event:setSkillData(self, "cancel_cost", true)
  end,
  on_use = function(self, event, target, player, data)
    local to = event:getCostData(self).tos[1]
    to:drawCards(2, self.name)
  end
})


return lincai